#ifndef  __INDEX_READER_H_
#define  __INDEX_READER_H_

#include "termlist.h"
#include "logger.h"
#include "sign64.h"
#include "common.h"
#include "ini_file_reader.h"

#include <fcntl.h>
#include <sys/mman.h>
#include <new>

typedef struct index_file_t
{
    int fd;
    uint64_t size;
    void* mmapPtr;
}IndexFile;

class IndexReader
{
public:
        IndexReader(){}
        ~IndexReader()
        {
            for(int i = 0; i < LEVEL_NUM; ++i)
            {
                delete[] m_index0[i];
            }
        }
        int Init(const char* indexPath);
        int ReadIndex(uint64_t termSign, IndexList* indexList, int level);
        int ReadIndex(char* termStr, IndexList* indexList, int level);
private:
        idx_index0_t* m_index0[LEVEL_NUM];
        IndexFile* m_index1_file[LEVEL_NUM];
        IndexFile* m_index2_file[LEVEL_NUM];
        int32_t m_num[LEVEL_NUM];
};














#endif  //__INDEX_READER_H_

/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */
